// Get userprefs
var prefs = new _IG_Prefs(__MODULE_ID__);

// Based on user input, display personal greeting
function displayGreeting () {
	// Create Date object
	var today = new Date();
	
	// Get current time.
	var time = today.getTime();
	var salutation;
	
	// Based on the time of day, display an appropriate greeting
	var hour = today.getHours();
	if (hour < 12)
		salutation = "Morning";
	else if (hour > 17)
		salutation = "Evening";
	else salutation = "Afternoon";
	
	// Build HTML string to display message
	var html = "";
    var element = document.getElementById('content_div');
	element.style.height=250;
	
	// Set the background color according to the mycolor userpref
	element.style.backgroundColor=prefs.getString("mycolor"); 
	
	// Display a greeting based on the myname userpref
	html += "<br><h2>Good " + salutation + ", " + prefs.getString("myname") + "!!!</h2><br>"; 
	
	// If the "Show Photo?" checkbox is checked, display photo.
	if (prefs.getBool("mychoice")==true) {
		html += '<img src="' + prefs.getString("myphoto") + '">'; 
	}
	_gel("content_div").innerHTML = html;
}
_IG_RegisterOnloadHandler(displayGreeting);